package com.caiyouxi.system.controller;

import com.caiyouxi.boss.buser.model.SysUserProfileBean;
import com.caiyouxi.common.bean.ResData;
import com.caiyouxi.common.service.BaseService;
import com.caiyouxi.system.model.SettingsBean;
import com.caiyouxi.system.service.SysSetingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("sys_settings")
public class SysSetingController extends BaseService{
    @Autowired
    private SysSetingService service;

    /***
     * 通过key获取对象
     */
    @RequestMapping("get_setting_bean")
    public ResData get_setting_bean(@RequestBody SettingsBean bean){
        return success(service.get_setting_bean(bean.getKey()));
    }

    /***
     *通过key获取value值
     */
    @RequestMapping("get_setting_value")
    public ResData get_setting_value(@RequestBody SettingsBean bean){
        return success(service.get_setting_value(bean.getKey()));
    }

    /**
     *查询所有system setting数据
     */
    @RequestMapping("selectAll")
    public ResData selectAll(){
        return success(service.selectAll());
    }

    /**
     * 查询登陆是否需要验证码
     * */
    @RequestMapping("select_is_aptcha")
    public ResData select_is_aptcha(@RequestParam("username")SysUserProfileBean bean){
        return success(service.select_is_aptcha(bean));
    }

    /**
     * 添加
     * */
    @RequestMapping("add_setting")
    public ResData add_setting(@RequestBody SettingsBean bean){
        return service.add_setting(bean);
    }

    /**
     * 更新
     * */
    @RequestMapping("update_setting")
    public ResData update_setting(@RequestBody SettingsBean bean){
        return service.update_setting(bean);
    }

    /**
     * 删除
     * */
    @RequestMapping("delete_setting")
    public ResData delete_setting(@RequestBody SettingsBean bean){
        return service.delete_setting(bean);
    }

}
